package iotest.chario;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;

public class CopyFiles2 {

	public static void main(String[] args) {
		fileCopy();
	}
	

	private static void fileCopy() {
		Reader fileReader = null;
		BufferedReader bufferedReader = null;
		Writer fileWriter = null;
		BufferedWriter bufferedWriter = null;
		try {
			fileReader = new FileReader("src/test/Test.java");
			fileWriter =  new FileWriter("Test_copy.java");
			bufferedReader = new BufferedReader(fileReader);
			bufferedWriter = new BufferedWriter(fileWriter);
			
			String line = null;
			while ((line = bufferedReader.readLine())!=null) {
				bufferedWriter.write(line);
				bufferedWriter.append("\r\n");
			}
			bufferedWriter.flush();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			try {
				if (bufferedWriter!=null) {
					bufferedWriter.close();
				}
				if (bufferedReader!=null) {
					bufferedReader.close();
				}
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

}
